#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>

using namespace std;
using PII = pair<int, int>;

const int N = 1e5 + 10, M = 6e5 + 10, MOD = 100003;

int n, m;
int h[N], e[M], ne[M], idx;
int dist[N];
int cnt[N];
int st[N];

void add(int a, int b)
{
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx++;
}

void dijkstra()
{
    priority_queue<PII, vector<PII>, greater<PII>> que;
    dist[1] = 0;
    cnt[1] = 1;
    que.push({dist[1], 1});

    while (que.size())
    {
        PII temp = que.top();
        que.pop();

        int ver = temp.second, dis = temp.first;
        if (st[ver])
            continue;
        st[ver] = true;

        for (int u = h[ver]; u != -1; u = ne[u])
        {
            int j = e[u];
            if (dist[j] > dis + 1)
            {
                dist[j] = dis + 1;
                cnt[j] = cnt[ver];
                que.push({dist[j], j});
            }
            else if (dist[j] == dis + 1)
            {
                cnt[j] = (cnt[j] + cnt[ver]) % MOD;
            }
        }
    }
}

int main()
{
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    memset(dist, 0x3f, sizeof dist);
    memset(h, -1, sizeof h);

    scanf("%d%d", &n, &m);

    int a, b;
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d", &a, &b);
        add(a, b), add(b, a);
    }

    dijkstra();

    for (int i = 1; i <= n; i++)
    {
        printf("%d\n", cnt[i]);
    }

    return 0;
}